<?php require admin_tpl('header')?>

<div class="tab">
	<ul>
		<?php if ( check_perm('blog','post') ) { ?>
		<li><a href="?mod=blog&ac=write">撰写文章</a></li>
		<?php } ?>
		<li><a href="?mod=blog&ac=list">文章列表</a></li>
		<?php if ( check_perm('blog','addcate') ||  check_perm('blog','editcate') ||  check_perm('blog','delcate')) {?>
		<li><a href="?mod=blog&ac=category">文章分类</a></li>
		<?php } ?>
		<?php if ( is_founder() ) { ?>
		<li><a href="?mod=blog&ac=blogmeta" class="on">自定义域</a></li>
		<?php }?>
	</ul>
</div>

<div class="main">

	<?php if ( $do == 'list' ) { ?>
	<table cellspacing="0" class="datalist" id="list">
		<tr>
			<th width="150" class="firstcol">名称</th>
			<th width="120">类型</th>
			<th>默认值</th>
			<th width="120">操作</th>
		</tr>
		<?php if ( $result ) { ?>
		<?php foreach ( $result as $row ) { ?>
		<tr>
			<td><?php echo $row['name']?></td>
			<td align="center">
			<?php
			switch ( $row['type'] ) {
				case 'input' : echo '单行文本'; break;
				case 'textarea' : echo '多行文本'; break;
			}
			?>
			</td>
			<td><?php echo $row['default']?>&nbsp;</td>
			<td align="center"><a href="?mod=blog&ac=blogmeta&do=edit&name=<?php echo rawurlencode($row['name'])?>">编辑</a> | <a href="?mod=blog&ac=blogmeta&do=del&name=<?php echo rawurlencode($row['name'])?>">删除</a></td>
		</tr>
		<?php } ?>
		<?php } else { ?>
		<tr>
			<td colspan="5">暂无自定义域...</td>
		</tr>
		<?php } ?>

	</table>

	<br />
	<?php } ?>

	<form name="save" method="post" action="?mod=blog&ac=blogmeta&do=save">
	<input type="hidden" name="dosubmit" value="yes" />
	<table class="sub panel" cellspacing="0">
		<tr>
			<th colspan="2" class="title"><?php echo $do=='edit' ? '编辑':'添加';?>自定义域</th>
		</tr>
		<tr>
			<td width="80">名称：</td>
			<td>
			<input type="text" name="name" size="50" value="<?php echo $meta['name']?>" <?php if ($do=='edit') {echo 'readonly="true"';}?> />
			<span>必须由汉字、字母、数字、下划线组成</span>
			</td>
		</tr>
		<tr>
			<td>类型：</td>
			<td>
			<input type="radio" name="value[type]" value="input" class="radio" id="type_input" <?php if ( empty($meta['type']) || $meta['type'] == 'input' ) { echo 'checked';} ?> /><label for="type_input">单行文本</label>
			<input type="radio" name="value[type]" value="textarea" class="radio" id="type_textarea" <?php if ( $meta['textarea'] == 'input' ) { echo 'checked';} ?> /><label for="type_textarea">多行文本</label>
			</td>
		</tr>
		<tr>
			<td>默认值：</td>
			<td><input type="text" name="value[default]" size="50" value="<?php echo $meta['default']?>" /></td>
		</tr>
		<tr>
			<td></td>
			<td>
			<input type="submit" value=" 提 交 " class="button" />
			<?php if ( $do == 'edit' ) { ?>
			<input type="button" value=" 返 回 " class="button" onclick="history.back()" />
			<?php } ?>
			</td>
		</tr>
	</table>
	</form>
</div>

<?php require admin_tpl('footer')?>